package com.zg.message.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.common.core.R;
import com.zg.message.domain.req.MsgTemplateAddReq;
import com.zg.message.domain.req.MsgTemplateEditReq;
import com.zg.message.domain.req.MsgTemplatePageReq;
import com.zg.message.domain.vo.MsgTemplateVo;
import com.zg.message.service.MsgTemplateService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>Description: </p>
 *
 * @author zhanfeng.liang
 * @since 2025/5/22 10:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/message/template")
@Slf4j
@Api(tags = "消息模板管理")
public class MsgTemplateController {
    private final MsgTemplateService templateService;

    @PostMapping("/page")
    public R page(@RequestBody MsgTemplatePageReq pageReq) {
        Page<MsgTemplateVo> page = templateService.page(pageReq, MsgTemplateVo.class);
        return R.success(page);
    }


    @PostMapping("/add")
    public R add(@RequestBody MsgTemplateAddReq addReq) {
        templateService.add(addReq);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody MsgTemplateEditReq editReq) {
        templateService.edit(editReq);
        return R.success();
    }

    @PostMapping("/remove")
    public R remove(@RequestBody List<Long> ids) {
        templateService.remove(ids);
        return R.success();
    }
}
